package com.shanzhu.tourism.controller;

import com.shanzhu.tourism.domain.Result;
import com.shanzhu.tourism.domain.Ticket;
import com.shanzhu.tourism.domain.TicketOrder;
import com.shanzhu.tourism.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: cc
 * @Date: 2025/03/28/14:54
 **/
@RestController
@RequestMapping("/ticket")
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @GetMapping("/list")
    public Result list(Ticket ticket) {
        return ticketService.getTicketList(ticket);
    }

    @PostMapping("/book")
    public Result book(@RequestBody TicketOrder order) {
        return ticketService.bookTicket(order);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") Long ticketId) {
        Ticket ticket = ticketService.getTicketById(ticketId);
        return Result.success(ticket);
    }
}